
#include <avr/io.h>
#include "adc.h"

void adc_init(void){
	
	//Write code to initialize the ADC.
	ADMUX |= (1<<MUX1) | (1<<MUX2) | (1<<REFS0) | (1<<REFS1); //Select ADC6
	ADCSRA |= (1<<ADEN);

}

uint16_t adc_read(void){

	uint16_t adc_value = 0;
	
	//Write some code to read a value from an ADC channel.
	ADCSRA |= (1<<ADSC);
	//while (!(ADCSRA &= (1<<ADIF))); //Wait for conversion complete flag... PS: FOR INTERUPT
	adc_value = ADC;
	return adc_value;
	
}
